package org.btik.light.server.platform.event;

import org.btik.context.AppContext;
import org.btik.context.ContextHolder;
import org.btik.context.event.SystemShutdownHook;
import org.btik.context.handler.ShutdownHandler;
import org.springframework.boot.SpringApplication;

public class LightSeverShutdownHandler implements ShutdownHandler, ContextHolder {
    private AppContext appContext;

    @Override
    public void register(SystemShutdownHook systemShutDownHook) {
        SpringApplication.getShutdownHandlers().add(() -> systemShutDownHook.beforeShutdown(appContext));
    }

    @Override
    public void hold(AppContext context) {
        this.appContext = context;
    }
}
